<?php include '../public/header.php' ?>
<?php include '../public/header_public.php' ?>
<body class="laytp-container">
<div style="height: 45px"></div>
<div id="opt_nav">
</div>
<div id="dialog">
    <div class="page-title" id="page-title">
        <div class="page-title-con">
            <span class="title">供应商-项目应付报表</span>
            <div class="move_title"></div>
            <div class="page-title-opt-list">
                <span id="page-close" class="page-close" onclick="layer_close()">×</span>
            </div>
        </div>
    </div>
</div>

<div class="layui-card" id="search-form">
    <div class="layui-card-body">
        <form class="layui-form" id="TableSearchFormId" lay-filter="TableSearchForm" onkeydown="keyTableSearch('TableSearchForm', 'datalist')">
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-md3">
                        <label class="layui-form-label">供应商</label>
                        <div class="layui-input-block">
                            <input type="text" name="gonger" id="gonger" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <div class="layui-form-item search-div">
                            <div class="layui-form-item layui-inline">
                                <button class="laytp-btn laytp-btn-md laytp-btn-primary" id="TableSearchButton" type="button"><i class="layui-icon layui-icon-search"></i>查询</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="layui-card" id="table-card">
    <div class="layui-card-body">
        <div class="layui-row">
            <div class="layui-col-md12" id="table_list">
                <div class="layui-card-body">
                    <table id="datalist" lay-filter="datalist"></table>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="test-dropdown-toolbar-barDemo">
    <div class="tab-list-authbut">
    </div>
</script>
<script type="text/html" id="toolbarDemo">
    <div class = "layui-btn-container">
    </div>
</script>
<script>


    var param_gonger = decodeURI(getQueryVariable('gonger') || '') || '';
    if(param_gonger){
        $("#gonger").val(param_gonger);
        $("#gonger").prop('disabled', true);
        $("#gonger").addClass('disabled');
    }

    layui.use(["laytp",'laypage','table','dropdown','form','soulTable'], function () {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable;


        $('#TableSearchReset').click(function () {
            $('.xmselect_div>xm-select').find('.xm-label-block').css('display','none');
            $('.xmselect_div').append('<div class="xmselect_title">请选择</div>');
            searchTableFunc(form, table)
        });

        setSouTableExport('供应商-项目应付报表');
        var mytable = table.render({
            elem: "#datalist",id: "datalist"
            ,url: facade.url(ask_gong_gong_tong),where: {gonger:param_gonger}, page: true
            ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: TabInit.toolbar, overflow: TabInit.overflow
            ,defaultToolbar: TabInit.defaultToolbar,filter: TabInit.filter
            ,request: TabInit.request,response: TabInit.response,contextmenu:get_table_contextmenu(soulTable)
            ,text: TabInit.text,totalRow: true,limits: [10,15,30,50,100],limit: 10
            ,parseData: function (res) {

                render_from();
                return {
                    "code": res.code,
                    "msg": res.message,
                    "count": res.data.data.total,
                    "data": res.data.data.data
                };
            }
            , cols: [[
                {type: "checkbox", fixed: 'left'}
                ,{type:'numbers',title:'序号',totalRowText: '合计',fixed:'left'}
                ,{field: 'gonger', title: '供应商',merge:true}
                ,{field: 'name', title: '项目名称'}
                ,{field: 'lei_caihe', title: '采购合同总额(含变更) A',align:'right',event: 'contract_cai',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.lei_caihe)+'</span>';
                    }}
                ,{field: 'lei_jie', title: '供应商累计结算 B',align:'right',event: 'gonglei',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.lei_jie)+'</span>';
                    }}
                ,{field: 'lei_piaoshou', title: '累计收票 C',align:'right',event: 'piao_shou_hui',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.lei_piaoshou)+'</span>';
                    }}
                ,{field: 'lei_payment_engin', title: '累计付款 D',align:'right',event: 'payment_engin',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.lei_payment_engin)+'</span>';
                    }}
                ,{field: 'lei_bijie', title: '付款比例按结算 D/B',align:'right',templet: function(d){
                        return '<span>'+parseFormatNum(d.lei_bijie)+'</span>';
                    }}
                ,{field: 'lei_bihe', title: '付款比例按合同  D/A',align:'right',templet: function(d){
                        return '<span>'+parseFormatNum(d.lei_bihe)+'</span>';
                    }}
                ,{field: 'lei_daijie', title: '待付金额按结算 B-D',align:'right',templet: function(d){
                        return '<span>'+parseFormatNum(d.lei_daijie)+'</span>';
                    }}
                ,{field: 'lei_daihe', title: '待付金额按合同 A-D',align:'right',templet: function(d){
                        return '<span>'+parseFormatNum(d.lei_daihe)+'</span>';
                    }}
                ,{field: 'business_name', title: '项目属性'}
                ,{field: 'state_name', title: '项目状态'}
                ,{field: 'chanid_name', title: '项目所属单位'}
            ]]
            , done: function (res) {
                soulTable.render(this);

                // 处理列表fixed的高度问题
                $('div[lay-id="datalist"] .layui-table-main>table>tbody>tr').each(function (i) {
                    var height = $(this).height();
                    $('div[lay-id="datalist"] .layui-table-fixed-l>.layui-table-body>table>tbody>tr')
                        .eq(i).css('cssText','height:'+height+'px !important');
                    $('div[lay-id="datalist"] .layui-table-fixed-r>.layui-table-body>table>tbody>tr')
                        .eq(i).css('cssText','height:'+height+'px !important');
                });
            }
        });

        table.on('tool(datalist)',function (obj) {
            var data = obj.data;
            if(obj.event === 'contract_cai'){
                if(data.id && data.id > 0){
                    openPage('../contract_cai/tong.php?enginname='+encodeURI(data.name)+'&status=1'+'&gonger='+encodeURI(data.gonger), '80%', '80%');
                }
            }
            if(obj.event === 'piao_shou_hui'){
                if(data.id && data.id > 0){
                    openPage('../piao_shou_hui/tong.php?enginname='+encodeURI(data.name)+'&status=1'+'&gonger='+encodeURI(data.gonger), '80%', '80%');
                }
            }
            if(obj.event === 'payment_engin'){
                if(data.id && data.id > 0){
                    openPage('../payment_engin/tong.php?enginname='+encodeURI(data.name)+'&status=1'+'&gonger='+encodeURI(data.gonger), '80%', '80%');
                }
            }
            if(obj.event === 'gonglei'){
                if(data.id && data.id > 0){
                    openPage('../tong_pub/gonglei.php?enginid='+encodeURI(data.id)+'&gonger='+encodeURI(data.gonger), '80%', '80%');
                }
            }
        });


        listTableSearch(form, table);
    });




</script>
</body>
</html>
